// 通道信息配置
<template>
  <div class="role_box my_loading" v-loading="loading">
    <!-- 交流通道 -->
    <div class="dc_box">
      <div class="ac_title">交流通道</div>
      <ul class="role_up" v-if="R_0003000d < 1">
        暂未获取到数据 可刷新重试
      </ul>
      <ul class="role_up" v-else>
        <!-- v-for="(item, index) in AcList" -->
        <!-- {{Ac.slice(0,R_0003000d)}} -->
        <li class="box_top" v-for="(item, index) in Ac.slice(0, R_0003000d)" :key="index" @click.stop="goItem(index, item, 'Ac')">
          <div shadow="hover" :class="[currentAcIndex === index ? 'selected' : '', 'unselected']">
            <div class="clear headerBox">
              <img :src="getImgUrl(Number(item[`R_000${AcArr[index]}0002`]) !== 1 ? 'AcOff' : 'AcOn')" class="image" />
              <div class="passName">
                <h3 class="title_rloe">交流通道{{ index + 1 }}</h3>
                <el-tooltip class="item" effect="dark" :content="item[`R_000${AcArr[index]}0003`]" placement="top-start">
                  <span class="params_rloe">{{ item[`R_000${AcArr[index]}0003`] }}</span>
                </el-tooltip>
              </div>
              <el-tooltip class="item" effect="dark" content="对应智能运维主机上的通道号" placement="top-start">
                <span class="angleSign">{{ index + 7 }}</span>
              </el-tooltip>
            </div>
            <div class="enable">
              <!-- 通道使能 -->
              <div class="channelSpace">
                <span class="enableName">通道使能</span>
                <el-switch
                  :value="item[`R_000${AcArr[index]}0002`]"
                  :inactive-value="0"
                  :active-value="1"
                  :active-icon-class="AcIcon[0][`icon${index}`]"
                  :disabled="AcDisable[0][`d${index}`]"
                  @click.native.stop="btnMessage(item, index, 'currentAcIndex', AcDisable[0], AcIcon[0], `000${AcArr[index]}0002`, 0, 'Ac')"
                ></el-switch>
              </div>
              <!-- 跳/合闸 -->
              <div class="channelSpace">
                <span class="enableName">跳/合闸</span>
                <!-- :value="item[`R_010f000${index + 5}`]" -->
                <!-- :inactive-value="0"
                  :active-value="1" -->
                <!-- @click.native.stop="btnMessage(item, index, 'currentAcIndex', AcDisable[1], AcIcon[1], `010f000${index + 5}`, 1, 'Ac')" -->
                <!-- 多个判断值 更改为0 是开 其他是关 -->
                <el-switch
                  :value="item[`R_0102001${index + 5}`]"
                  :inactive-value="1"
                  :active-value="0"
                  :active-icon-class="AcIcon[1][`icon${index}`]"
                  :disabled="AcDisable[1][`d${index}`]"
                  @click.native.stop="btnMessage(item, index, 'currentAcIndex', AcDisable[1], AcIcon[1], `0102001${index + 5}`, 1, 'Ac')"
                ></el-switch>
              </div>
              <!-- IP使能 -->
              <div class="channelSpace">
                <span class="enableName">IP使能</span>
                <el-switch
                  :value="item[`R_000${AcArr[index]}0001`]"
                  :inactive-value="0"
                  :active-value="1"
                  :active-icon-class="AcIcon[2][`icon${index}`]"
                  :disabled="AcDisable[2][`d${index}`]"
                  @click.native.stop="btnMessage(item, index, 'currentAcIndex', AcDisable[2], AcIcon[2], `000${AcArr[index]}0001`, 2, 'Ac')"
                ></el-switch>
              </div>
            </div>
            <!-- 展开/关闭信息面板按钮 -->
            <div class="arrow">
              <!-- <svg class="iconfont" aria-hidden="true" @click.stop="displayInfor('Ac', currentAcIndex === index)"> -->
              <svg class="iconfont" aria-hidden="true" @click.stop="displayInfor('Ac', index)">
                <use :xlink:href="`#${isAcInfor && currentAcIndex === index ? 'el-icon-myPut_it_away' : 'el-icon-myopen'}`" style="font-size: 50px" />
              </svg>
            </div>
          </div>
        </li>
      </ul>
    </div>
    <!-- 直流通道 -->
    <div class="dc_box">
      <div class="dc_title">直流通道</div>
      <ul class="role_up" v-if="R_0003000c < 1">
        暂未获取到数据 可刷新重试
      </ul>
      <ul class="role_up" v-else>
        <!-- {{R_0003000c}} -->
        <!-- v-for="(item, index) in DcList" -->
        <li class="box_top" v-for="(item, index) in Dc.slice(0, R_0003000c)" :key="index" @click.stop="goItem(index, item, 'Dc')">
          <div shadow="hover" :class="[currentDcIndex === index ? 'selected' : '', 'unselected']">
            <div class="clear headerBox">
              <!-- 根据通道使能判断 -->
              <img :src="getImgUrl(Number(item[`R_000${DcArr[index]}000a`]) !== 1 ? 'DcOff' : 'DcOn')" class="image" />
              <div class="passName">
                <h3 class="title_rloe">直流通道{{ index + 1 }}</h3>
                <el-tooltip class="item" effect="dark" :content="item[`R_000${DcArr[index]}0005`]" placement="top-start">
                  <span class="params_rloe">{{ item[`R_000${DcArr[index]}0005`] }}</span>
                </el-tooltip>
              </div>
              <el-tooltip class="item" effect="dark" content="对应智能运维主机上的通道号" placement="top-start">
                <span class="angleSign">{{ index + 1 }}</span>
              </el-tooltip>
            </div>
            <div class="enable">
              <div class="channelSpace">
                <span class="enableName">通道使能</span>
                <el-switch
                  :value="item[`R_000${DcArr[index]}000a`]"
                  :active-value="1"
                  :inactive-value="0"
                  :active-icon-class="DcIcon[0][`icon${index}`]"
                  :disabled="DcDisable[0][`d${index}`]"
                  @click.native.stop="btnMessage(item, index, 'currentDcIndex', DcDisable[0], DcIcon[0], `000${DcArr[index]}000a`, 0, 'Dc')"
                ></el-switch>
              </div>
              <div class="channelSpace">
                <span class="enableName">跳/合闸</span>
                <!-- :inactive-value="1"
                :active-value="0"-->
                <el-switch
                  :value="item[`R_010200${OnOrInSwitch[index]}`]"
                  :inactive-value="0"
                  :active-value="1"
                  :active-icon-class="DcIcon[1][`icon${index}`]"
                  :disabled="DcDisable[1][`d${index}`]"
                  @click.native.stop="btnMessage(item, index, 'currentDcIndex', DcDisable[1], DcIcon[1], `010200${OnOrInSwitch[index]}`, 1, 'Dc')"
                ></el-switch>
              </div>
              <div class="channelSpace">
                <span class="enableName">通道保护使能</span>
                <el-switch
                  :value="item[`R_000${DcArr[index]}0009`]"
                  :active-value="2"
                  :inactive-value="0"
                  :active-icon-class="DcIcon[2][`icon${index}`]"
                  :disabled="DcDisable[2][`d${index}`]"
                  @click.native.stop="btnMessage(item, index, 'currentDcIndex', DcDisable[2], DcIcon[2], `000${DcArr[index]}0009`, 2, 'Dc')"
                ></el-switch>
              </div>
              <div class="channelSpace">
                <span class="enableName">IP使能</span>
                <el-switch
                  :value="item[`R_000${DcArr[index]}0008`]"
                  :active-value="1"
                  :inactive-value="0"
                  :active-icon-class="DcIcon[3][`icon${index}`]"
                  :disabled="DcDisable[3][`d${index}`]"
                  @click.native.stop="btnMessage(item, index, 'currentDcIndex', DcDisable[3], DcIcon[3], `000${DcArr[index]}0008`, 3, 'Dc')"
                ></el-switch>
              </div>
            </div>
            <!-- 展开/关闭信息面板按钮 -->
            <div class="arrow">
              <!-- <svg class="iconfont" aria-hidden="true" @click.stop="displayInfor('Dc', currentDcIndex === index)"> -->
              <svg class="iconfont" aria-hidden="true" @click.stop="displayInfor('Dc', index)">
                <use :xlink:href="`#${isDcInfor && currentDcIndex === index ? 'el-icon-myPut_it_away' : 'el-icon-myopen'}`" style="font-size: 50px" />
              </svg>
            </div>
          </div>
        </li>
      </ul>
    </div>
    <!-- 数据 -->
    <div class="bigMax_box">
      <!-- 交流 -->
      <div class="Breadcrumb_ac" v-if="R_0003000d > 0 && type === 'Ac'" v-loading="acContentLoad" v-show="isAcInfor">
        <div class="channelName">
          <span>交流通道{{ currentAcIndex + 1 }}</span>
          <el-button type="primary" @click="bindDevice()" :disabled="bindFlag">绑定设备</el-button>
          <el-button
            type="danger"
            @click="unBindDevice(currentAcIndex + 7)"
            :disabled="bindFlag || (AcContent[currentAcIndex][0][`R_000${AcArr[currentAcIndex]}0003`] === 'NULL' && AcContent[currentAcIndex][1][`R_000${AcArr[currentAcIndex]}0004`] === '127.0.0.1')"
            :loading="unBindFlag"
            >解绑</el-button
          >
        </div>
        <el-row class="big_box">
          <el-col :sm="8" :md="8" :lg="8" :xl="8">
            <div class="left_box">
              <el-form :model="AcContent[currentAcIndex][0]" label-width="130px">
                <el-row type="flex" justify="center">
                  <el-col :span="21">
                    <el-form-item label="绑定设备名称" class="margin_top">
                      <el-input v-model.trim="AcContent[currentAcIndex][0][`R_000${AcArr[currentAcIndex]}0003`]" placeholder="绑定设备名称" :disabled="true"></el-input>
                    </el-form-item>
                    <el-form-item label="挂载设备国标编码" class="margin_top">
                      <!-- 更新于2021-01-28 -->
                      <!-- <el-input
                        v-model.trim="AcContent[currentAcIndex][0][`R_000${AcArr[currentAcIndex]}0007`]"
                        placeholder="20位国标编码(数字)"
                        :disabled="disableFlag1"
                        onkeyup="this.value = this.value.replace(/[^\d.]/g,'');"
                        maxlength="20"
                      ></el-input> -->
                      <el-input v-model.trim="AcContent[currentAcIndex][0][`R_000${AcArr[currentAcIndex]}0007`]" placeholder="20位国标编码(数字)" :disabled="true" maxlength="20"></el-input>
                    </el-form-item>
                    <!-- <el-form-item label="第三方关联编码" class="margin_top">
                      <el-input
                        v-model.trim="AcContent[currentAcIndex][0][`R_000${AcArr[currentAcIndex]}0008`]"
                        placeholder="第三方关联编码"
                        :disabled="disableFlag1"
                        onkeyup="this.value = this.value.replace(/[^\d.]/g,'');"
                        maxlength="12"
                      ></el-input>
                    </el-form-item> -->
                    <!-- <el-form-item class="margin_top">
                      <el-button type="primary" class="button" :disabled="disableFlag1" :loading="btnD1" @click="AcFisrtSubmit(currentAcIndex)">提交</el-button>
                    </el-form-item> -->
                  </el-col>
                </el-row>
              </el-form>
            </div>
          </el-col>
          <el-col :sm="8" :md="8" :lg="8" :xl="8">
            <div class="right_box">
              <el-form :model="AcContent[currentAcIndex][1]" label-width="120px" ref="refAc" :validate-on-rule-change="false">
                <el-row type="flex" justify="center">
                  <el-col :span="21">
                    <!-- <el-form-item
                      label="目的IP地址"
                      class="margin_top"
                      :rules="[
                        { required: true, message: '请输入本地ip地址', trigger: 'blur' },
                        { pattern: /^((2(5[0-5]|[0-4]\d))|[0-1]?\d{1,2})(\.((2(5[0-5]|[0-4]\d))|[0-1]?\d{1,2})){3}$/, message: '请输入正确的IP地址', trigger: 'blur' },
                      ]"
                      :prop="`R_000${AcArr[currentAcIndex]}0004`"
                    >
                      <el-input v-model.trim="AcContent[currentAcIndex][1][`R_000${AcArr[currentAcIndex]}0004`]" placeholder="请输入IP地址" :disabled="disableFlag2"></el-input>
                    </el-form-item> -->
                    <el-form-item label="目的IP地址" class="margin_top">
                      <el-input v-model.trim="AcContent[currentAcIndex][1][`R_000${AcArr[currentAcIndex]}0004`]" placeholder="请输入IP地址" :disabled="true"></el-input>
                    </el-form-item>
                    <!-- <el-form-item
                      label="子网掩码"
                      class="margin_top"
                      :rules="[
                        { required: true, message: '请输入子网掩码', trigger: 'blur' },
                        {
                          pattern: /^((2(5[0-5]|[0-4]\d))|[0-1]?\d{1,2})(\.((2(5[0-5]|[0-4]\d))|[0-1]?\d{1,2})){3}$/,
                          message: '请输入正确的子网掩码',
                          trigger: 'blur',
                        },
                      ]"
                      :prop="`R_000${AcArr[currentAcIndex]}0005`"
                    >
                      <el-input v-model.trim="AcContent[currentAcIndex][1][`R_000${AcArr[currentAcIndex]}0005`]" placeholder="请输入子网掩码" :disabled="disableFlag2"></el-input>
                    </el-form-item> -->
                    <!-- <el-form-item
                      label="端口"
                      class="margin_top"
                      :rules="[
                        { required: true, message: '请输入端口', trigger: 'blur' },
                        { pattern: /^(([0-9]|[1-9]\d{1,3}|[1-5]\d{4}|6[0-5]{2}[0-3][0-5]))$/, message: '请输入正确端口', trigger: 'blur' },
                      ]"
                      :prop="`R_000${AcArr[currentAcIndex]}0006`"
                    >
                      <el-input v-model.trim="AcContent[currentAcIndex][1][`R_000${AcArr[currentAcIndex]}0006`]" placeholder="请输入端口" :disabled="disableFlag2"></el-input>
                    </el-form-item> -->
                    <el-form-item label="端口" class="margin_top">
                      <el-input v-model.trim="AcContent[currentAcIndex][1][`R_000${AcArr[currentAcIndex]}0006`]" placeholder="请输入端口" :disabled="true"></el-input>
                    </el-form-item>
                    <!-- <el-form-item class="margin_top">
                      <el-button type="primary" class="button" :disabled="disableFlag2" :loading="btnD2" @click="AcSecondSubmit(currentAcIndex)">提交</el-button>
                    </el-form-item> -->
                  </el-col>
                </el-row>
              </el-form>
            </div>
          </el-col>
          <!-- <el-col :sm="8" :md="8" :lg="8" :xl="8">
            <div class="right_box">
              <el-form label-width="180px">
                <el-row type="flex" justify="center">
                  <el-col :span="21">
                    <el-form-item label="连续时间(秒)" class="margin_top">
                      <el-input placeholder="请输入连续时间" disabled></el-input>
                    </el-form-item>
                    <el-form-item label="设备保护最小电流(mA)" class="margin_top">
                      <el-input placeholder="请输入设备保护最小电流" disabled></el-input>
                    </el-form-item>
                    <el-form-item label="设备保护最大电流(mA)" class="margin_top">
                      <el-input placeholder="请输入设备保护最大电流" disabled></el-input>
                    </el-form-item>
                    <el-form-item label="电流AD偏置" class="margin_top">
                      <el-input placeholder="请输入电流AD偏置" disabled></el-input>
                    </el-form-item>
                    <el-form-item label="电流放大倍数" class="margin_top">
                      <el-input placeholder="请输入电流放大倍数" disabled></el-input>
                    </el-form-item>
                    <el-form-item class="margin_top">
                      <el-button type="primary" class="button" disabled>提交</el-button>
                    </el-form-item>
                  </el-col>
                </el-row>
              </el-form>
            </div>
          </el-col> -->
        </el-row>
      </div>
      <!-- 直流 -->
      <div class="Breadcrumb_ac" v-if="R_0003000c > 0 && type === 'Dc'" v-loading="dcContentLoad" v-show="isDcInfor">
        <div class="channelName">
          <span>直流通道{{ currentDcIndex + 1 }}</span>
          <el-button type="primary" @click="bindDevice()" :disabled="bindFlag">绑定设备</el-button>
          <el-button
            type="danger"
            @click="unBindDevice(currentDcIndex + 1)"
            :disabled="bindFlag || (DcContent[currentDcIndex][0][`R_000${DcArr[currentDcIndex]}0005`] === 'NULL' && DcContent[currentDcIndex][1][`R_000${DcArr[currentDcIndex]}0006`] === '127.0.0.1')"
            :loading="unBindFlag"
            >解绑</el-button
          >
        </div>
        <el-row class="big_box">
          <el-col :sm="8" :md="8" :lg="8" :xl="8">
            <div class="left_box">
              <el-form :model="DcContent[currentDcIndex][0]" label-width="130px">
                <el-row type="flex" justify="center">
                  <el-col :span="21">
                    <el-form-item label="绑定设备名称" class="margin_top">
                      <el-input v-model.trim="DcContent[currentDcIndex][0][`R_000${DcArr[currentDcIndex]}0005`]" placeholder="绑定设备名称" :disabled="true"></el-input>
                      <!-- <el-input v-model.trim="DcContent[currentDcIndex][0][`R_000${DcArr[currentDcIndex]}0005`]" placeholder="绑定设备名称" :disabled="disableFlag1"></el-input> -->
                    </el-form-item>
                    <el-form-item label="挂载设备国标编码" class="margin_top">
                      <!-- <el-input
                        v-model.trim="DcContent[currentDcIndex][0][`R_000${DcArr[currentDcIndex]}000d`]"
                        placeholder="20位国标编码"
                        :disabled="disableFlag1"
                        onkeyup="this.value = this.value.replace(/[^\d.]/g,'');"
                        maxlength="20"
                      ></el-input> -->
                      <el-input v-model.trim="DcContent[currentDcIndex][0][`R_000${DcArr[currentDcIndex]}000d`]" placeholder="20位国标编码" :disabled="true" maxlength="20"></el-input>
                    </el-form-item>
                    <!-- <el-form-item label="第三方关联编码" class="margin_top">
                      <el-input
                        v-model.trim="DcContent[currentDcIndex][0][`R_000${DcArr[currentDcIndex]}000e`]"
                        placeholder="第三方关联编码"
                        :disabled="disableFlag1"
                        onkeyup="this.value = this.value.replace(/[^\d.]/g,'');"
                        maxlength="12"
                      ></el-input>
                    </el-form-item> -->
                    <!-- <el-form-item class="margin_top">
                      <el-button type="primary" class="button" :disabled="disableFlag1" :loading="btnD1" @click="DcFisrtSubmit(currentDcIndex)">提交</el-button>
                    </el-form-item> -->
                  </el-col>
                </el-row>
              </el-form>
            </div>
          </el-col>
          <el-col :sm="8" :md="8" :lg="8" :xl="8">
            <div class="right_box">
              <el-form :model="DcContent[currentDcIndex][1]" label-width="120px" ref="refDc" :validate-on-rule-change="false">
                <el-row type="flex" justify="center">
                  <el-col :span="21">
                    <!-- <el-form-item
                      label="目的IP地址"
                      class="margin_top"
                      :rules="[
                        { required: true, message: '请输入本地ip地址', trigger: 'blur' },
                        { pattern: /^((2(5[0-5]|[0-4]\d))|[0-1]?\d{1,2})(\.((2(5[0-5]|[0-4]\d))|[0-1]?\d{1,2})){3}$/, message: '请输入正确的IP地址', trigger: 'blur' },
                      ]"
                      :prop="`R_000${DcArr[currentDcIndex]}0006`"
                    >
                      <el-input v-model.trim="DcContent[currentDcIndex][1][`R_000${DcArr[currentDcIndex]}0006`]" placeholder="请输入IP地址" :disabled="disableFlag2"></el-input>
                    </el-form-item> -->
                    <el-form-item label="目的IP地址" class="margin_top">
                      <el-input v-model.trim="DcContent[currentDcIndex][1][`R_000${DcArr[currentDcIndex]}0006`]" placeholder="请输入IP地址" :disabled="true"></el-input>
                    </el-form-item>
                    <!-- <el-form-item
                      label="子网掩码"
                      class="margin_top"
                      :rules="[
                        { required: true, message: '请输入子网掩码', trigger: 'blur' },
                        {
                          pattern: /^((2(5[0-5]|[0-4]\d))|[0-1]?\d{1,2})(\.((2(5[0-5]|[0-4]\d))|[0-1]?\d{1,2})){3}$/,
                          message: '请输入正确的子网掩码',
                          trigger: 'blur',
                        },
                      ]"
                      :prop="`R_000${DcArr[currentDcIndex]}0007`"
                    >
                      <el-input v-model.trim="DcContent[currentDcIndex][1][`R_000${DcArr[currentDcIndex]}0007`]" placeholder="请输入子网掩码" :disabled="disableFlag2"></el-input>
                    </el-form-item> -->
                    <!-- <el-form-item
                      label="端口"
                      class="margin_top"
                      :rules="[
                        { required: true, message: '请输入端口', trigger: 'blur' },
                        { pattern: /^[1-9]$|(^[1-9][0-9]$)|(^[1-9][0-9][0-9]$)|(^[1-9][0-9][0-9][0-9]$)|(^[1-6][0-5][0-5][0-3][0-5]$)/, message: '请输入正确端口', trigger: 'blur' },
                      ]"
                      :prop="`R_000${DcArr[currentDcIndex]}000c`"
                    >
                      <el-input v-model.trim="DcContent[currentDcIndex][1][`R_000${DcArr[currentDcIndex]}000c`]" placeholder="请输入端口" :disabled="disableFlag2"></el-input>
                    </el-form-item> -->
                    <el-form-item label="端口" class="margin_top">
                      <el-input v-model.trim="DcContent[currentDcIndex][1][`R_000${DcArr[currentDcIndex]}000c`]" placeholder="请输入端口" :disabled="true"></el-input>
                    </el-form-item>
                    <!-- <el-form-item class="margin_top">
                      <el-button type="primary" class="button" :disabled="disableFlag2" :loading="btnD2" @click="secondSubmit(currentDcIndex)">提交</el-button>
                    </el-form-item> -->
                  </el-col>
                </el-row>
              </el-form>
            </div>
          </el-col>
          <el-col :sm="8" :md="8" :lg="8" :xl="8">
            <div class="right_box">
              <el-form :model="DcContent[currentDcIndex][2]" label-width="180px">
                <el-row type="flex" justify="center">
                  <el-col :span="21">
                    <el-form-item label="连续时间(秒)" class="margin_top">
                      <el-input
                        v-model.trim="DcContent[currentDcIndex][2][`R_000${DcArr[currentDcIndex]}000b`]"
                        @input="handleInput($event, currentDcIndex, `R_000${DcArr[currentDcIndex]}000b`)"
                        placeholder="请输入连续时间"
                        :disabled="disableFlag3"
                      ></el-input>
                    </el-form-item>
                    <el-form-item label="设备保护最小电流(mA)" class="margin_top">
                      <el-input
                        v-model.trim="DcContent[currentDcIndex][2][`R_000${DcArr[currentDcIndex]}0001`]"
                        @input="handleInput($event, currentDcIndex, `R_000${DcArr[currentDcIndex]}0001`)"
                        placeholder="请输入设备保护最小电流"
                        :disabled="disableFlag3"
                      ></el-input>
                    </el-form-item>
                    <el-form-item label="设备保护最大电流(mA)" class="margin_top">
                      <el-input
                        v-model.trim="DcContent[currentDcIndex][2][`R_000${DcArr[currentDcIndex]}0002`]"
                        @input="handleInput($event, currentDcIndex, `R_000${DcArr[currentDcIndex]}0002`)"
                        placeholder="请输入设备保护最大电流"
                        :disabled="disableFlag3"
                      ></el-input>
                    </el-form-item>
                    <el-form-item label="电流AD偏置" class="margin_top">
                      <el-input
                        v-model.trim="DcContent[currentDcIndex][2][`R_000${DcArr[currentDcIndex]}0003`]"
                        @input="handleInput($event, currentDcIndex, `R_000${DcArr[currentDcIndex]}0003`)"
                        placeholder="请输入电流AD偏置"
                        :disabled="disableFlag3"
                      ></el-input>
                    </el-form-item>
                    <el-form-item label="电流放大倍数" class="margin_top">
                      <el-input
                        v-model.trim="DcContent[currentDcIndex][2][`R_000${DcArr[currentDcIndex]}0004`]"
                        @input="handleInput($event, currentDcIndex, `R_000${DcArr[currentDcIndex]}0004`)"
                        placeholder="请输入电流放大倍数"
                        :disabled="disableFlag3"
                      ></el-input>
                    </el-form-item>
                    <el-form-item class="margin_top">
                      <el-button type="primary" class="button" :disabled="disableFlag3" :loading="btnD3" @click="DcLastSubmit(currentDcIndex)">提交</el-button>
                    </el-form-item>
                  </el-col>
                </el-row>
              </el-form>
            </div>
          </el-col>
        </el-row>
      </div>
    </div>
    <!-- 修改提示窗 -->
    <el-dialog title="提示" :visible.sync="dialogStstusVisible" width="640px" @close="parentEvent">
      <statusPage :listStatus="listStatus" @child-event="closeDialog" />
    </el-dialog>
    <!-- 绑定设备弹窗 -->
    <el-dialog title="绑定设备" :visible.sync="dialogFormVisible" width="900px" @close="dialogClose">
      <el-form :model="bindDeviceSearch" :inline="true" :disabled="closeDisable">
        <el-form-item>
          <el-input v-model="bindDeviceSearch.deviceIp" placeholder="输入设备名称或设备IP" clearable></el-input>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" class="btnSizeStyle" @click="addOnSubmit">查询</el-button>
        </el-form-item>
      </el-form>
      <el-alert title="只显示与当前主机相同辖区内的资产设备信息。" :closable="false" type="warning" show-icon></el-alert>
      <el-table
        :data="AddtableData"
        style="width: 100%; margin-top: 15px"
        max-height="320px"
        border
        :header-cell-style="{ background: '#F5F5F6' }"
        :cell-class-name="selectClass"
        v-loading="addLoading"
        @select="selectF"
        @select-all="selectF"
        :row-class-name="tableRowClassName"
        @row-click="addRowClick"
      >
        <!-- :default-sort="{ prop: 'zcmc' }"  sortable -->
        <!-- 提示语句 -->
        <template slot="empty">{{ tableMessage }}</template>
        <el-table-column prop="zcmc" max-width="400" style="position: relative">
          <template slot="header">
            <span>设备名称</span>
          </template>
          <template slot-scope="scope">
            <el-radio-group v-model="selectVal" :disabled="closeDisable" @click.native.stop @change="radioChange(scope.row)">
              <el-radio :label="scope.$index">{{ scope.row.zcmc }}</el-radio>
            </el-radio-group>
          </template>
        </el-table-column>
        <el-table-column prop="sfmc" max-width="400" label="辖区">
          <template slot-scope="scope">
            <div>{{ scope.row.sfmc + scope.row.csmc + scope.row.qxmc + scope.row.xzjdmc }}</div>
          </template>
        </el-table-column>
        <el-table-column prop="ip" width="150" label="设备IP">
          <template slot-scope="scope">
            <div>{{ scope.row.ip }}</div>
          </template>
        </el-table-column>
        <el-table-column prop="gldk" width="100" label="端口">
          <template slot-scope="scope">
            <div>{{ scope.row.gldk }}</div>
          </template>
        </el-table-column>
      </el-table>
      <el-row style="padding: 15px 0">
        <el-col :span="12">
          <el-pagination
            background
            layout="prev, pager, next,total"
            @current-change="addHandleCurrentChange"
            :current-page.sync="addCurrentPage"
            :page-size="addPageSize"
            :total="addTotal"
            :disabled="closeDisable"
          ></el-pagination>
        </el-col>
        <el-col :span="12" align="right">
          <el-button @click="cancelBtn()" :disabled="closeDisable" class="btnSizeStyle">关 闭</el-button>
          <el-button type="primary" class="btnSizeStyle" @click="addDevice()" :disabled="selectVal === ''" :loading="closeDisable">确 定</el-button>
        </el-col>
      </el-row>
    </el-dialog>
  </div>
</template>
<script>
import { ziC } from '@/utils/allUrl'
import { getUrl } from '@/utils/getUrl.js'
import {
  againData,
  reset,
  initDcSwitch,
  initAcSwitch,
  isRequire,
  getKZMB,
  getXXMB,
  submitBtn,
  watchCurrentIndex,
  listStatusTips,
  getlist1,
  getlist2,
  sendContent,
  getSuccess,
  initSwitch,
} from '@/assets/js/role.js'
import { getUUID, isJSON, errorTips, overTimeTips, listTips, intervalTime, send, sendPing, newSocket } from '@/utils/websocket'
import enumData from '@/utils/enum.json' // 枚举
import statusPage from '@/components/mainboard/listStatusTip'
export default {
  // 跳合闸 0是开 1是关
  // 通道保护使能 2是开  1是关
  // 通道使能和ip使能都是  0是关  1是开
  data() {
    return {
      socket: '',
      setIntervalWesocketPush: null,
      dialogStstusVisible: false, // 修改弹出窗
      listStatus: [], // 修改项数组
      loading: true,
      R_0003000c: 0, // 直流总数
      R_0003000d: 0, // 交流总数
      Ac: [
        // 交流
        {
          // 交流通道1
          R_000b0003: '', // 通道设备名称
          R_000b0002: '', // 通道使能
          R_01020015: '', // 跳合闸 更新于2021/04/26 跳合闸id更改
          // R_010f0005: '', // 跳合闸
          R_000b0001: '', // IP使能
        },
        {
          // 交流通道2
          R_000c0003: '', // 通道设备名称
          R_000c0002: '', // 通道使能
          R_01020016: '', // 跳合闸
          // R_010f0006: '', // 跳合闸
          R_000c0001: '', // IP使能
        },
        {
          // 交流通道3
          R_000d0003: '', // 通道设备名称
          R_000d0002: '', // 通道使能
          R_01020017: '', // 跳合闸
          // R_010f0007: '', // 跳合闸
          R_000d0001: '', // IP使能
        },
        {
          // 交流通道4
          R_000e0003: '', // 通道设备名称
          R_000e0002: '', // 通道使能
          R_01020018: '', // 跳合闸
          // R_010f0008: '', // 跳合闸
          R_000e0001: '', // IP使能
        },
      ],
      Dc: [
        // 直流
        {
          R_00050005: '', // 通道设备名称
          R_0005000a: '', // 通道使能
          R_0102000f: '', // 跳合闸
          R_00050008: '', // IP使能
          R_00050009: '', // 通道保护使能
        },
        {
          R_00060005: '', // 通道设备名称
          R_0006000a: '', // 通道使能
          R_01020010: '', // 跳合闸
          R_00060008: '', // IP使能
          R_00060009: '', // 通道保护使能
        },
        {
          R_00070005: '', // 通道设备名称
          R_0007000a: '', // 通道使能
          R_01020011: '', // 跳合闸
          R_00070008: '', // IP使能
          R_00070009: '', // 通道保护使能
        },
        {
          R_00080005: '', // 通道设备名称
          R_0008000a: '', // 通道使能
          R_01020012: '', // 跳合闸
          R_00080008: '', // IP使能
          R_00080009: '', // 通道保护使能
        },
        {
          R_00090005: '', // 通道设备名称
          R_0009000a: '', // 通道使能
          R_01020013: '', // 跳合闸
          R_00090008: '', // IP使能
          R_00090009: '', // 通道保护使能
        },
        {
          R_000a0005: '', // 通道设备名称
          R_000a000a: '', // 通道使能
          R_01020014: '', // 跳合闸
          R_000a0008: '', // IP使能
          R_000a0009: '', // 通道保护使能
        },
      ],
      AcList: [],
      DcList: [],
      AcContent: [
        // 交流
        [
          {
            R_000b0003: '', // 设备名称
            R_000b0007: '', // 国标编码
            R_000b0008: '', // 第三方关联编码
          },
          {
            R_000b0004: '', // 目的ip地址
            R_000b0005: '', // 子网掩码
            R_000b0006: '', // 端口
          },
        ],
        [
          {
            R_000c0003: '', // 设备名称
            R_000c0007: '', // 国标编码
            R_000c0008: '', // 第三方关联编码
          },
          {
            R_000c0004: '', // 目的ip地址
            R_000c0005: '', // 子网掩码
            R_000c0006: '', // 端口
          },
        ],
        [
          {
            R_000d0003: '', // 设备名称
            R_000d0007: '', // 国标编码
            R_000d0008: '', // 第三方关联编码
          },
          {
            R_000d0004: '', // 目的ip地址
            R_000d0005: '', // 子网掩码
            R_000d0006: '', // 端口
          },
        ],
        [
          {
            R_000e0003: '', // 设备名称
            R_000e0007: '', // 国标编码
            R_000e0008: '', // 第三方关联编码
          },
          {
            R_000e0004: '', // 目的ip地址
            R_000e0005: '', // 子网掩码
            R_000e0006: '', // 端口
          },
        ],
      ],
      DcContent: [
        [
          {
            R_00050005: '', // 设备名称1
            R_0005000d: '', // 国标编码
            R_0005000e: '', // 第三方关联编码
          },
          {
            R_00050006: '', // 目的ip地址
            R_00050007: '', // 子网掩码
            R_0005000c: '', // 端口
          },
          {
            R_0005000b: '', // 连续时间
            R_00050001: '', // 设备保护最小电流
            R_00050002: '', // 设备保护最大电流
            R_00050003: '', // 电流AD偏置
            R_00050004: '', // 电流放大倍数
          },
        ],
        [
          {
            R_00060005: '', // 设备名称2
            R_0006000d: '', // 国标编码
            R_0006000e: '', // 第三方关联编码
          },
          {
            R_00060006: '', // 目的ip地址
            R_00060007: '', // 子网掩码
            R_0006000c: '', // 端口
          },
          {
            R_0006000b: '', // 连续时间
            R_00060001: '', // 设备保护最小电流
            R_00060002: '', // 设备保护最大电流
            R_00060003: '', // 电流AD偏置
            R_00060004: '', // 电流放大倍数
          },
        ],
        [
          {
            R_00070005: '', // 设备名称3
            R_0007000d: '', // 国标编码
            R_0007000e: '', // 第三方关联编码
          },
          {
            R_00070006: '', // 目的ip地址
            R_00070007: '', // 子网掩码
            R_0007000c: '', // 端口
          },
          {
            R_0007000b: '', // 连续时间
            R_00070001: '', // 设备保护最小电流
            R_00070002: '', // 设备保护最大电流
            R_00070003: '', // 电流AD偏置
            R_00070004: '', // 电流放大倍数
          },
        ],
        [
          {
            R_00080005: '', // 设备名称4
            R_0008000d: '', // 国标编码
            R_0008000e: '', // 第三方关联编码
          },
          {
            R_00080006: '', // 目的ip地址
            R_00080007: '', // 子网掩码
            R_0008000c: '', // 端口
          },
          {
            R_0008000b: '', // 连续时间
            R_00080001: '', // 设备保护最小电流
            R_00080002: '', // 设备保护最大电流
            R_00080003: '', // 电流AD偏置
            R_00080004: '', // 电流放大倍数
          },
        ],
        [
          {
            R_00090005: '', // 设备名称5
            R_0009000d: '', // 国标编码
            R_0009000e: '', // 第三方关联编码
          },
          {
            R_00090006: '', // 目的ip地址
            R_00090007: '', // 子网掩码
            R_0009000c: '', // 端口
          },
          {
            R_0009000b: '', // 连续时间
            R_00090001: '', // 设备保护最小电流
            R_00090002: '', // 设备保护最大电流
            R_00090003: '', // 电流AD偏置
            R_00090004: '', // 电流放大倍数
          },
        ],
        [
          {
            R_000a0005: '', // 设备名称6
            R_000a000d: '', // 国标编码
            R_000a000e: '', // 第三方关联编码
          },
          {
            R_000a0006: '', // 目的ip地址
            R_000a0007: '', // 子网掩码
            R_000a000c: '', // 端口
          },
          {
            R_000a000b: '', // 连续时间
            R_000a0001: '', // 设备保护最小电流
            R_000a0002: '', // 设备保护最大电流
            R_000a0003: '', // 电流AD偏置
            R_000a0004: '', // 电流放大倍数
          },
        ],
      ],
      AcContentClone: [],
      DcContentClone: [],
      AcArr: ['b', 'c', 'd', 'e'], // 交流
      DcArr: [5, 6, 7, 8, 9, 'a'], // 直流
      OnOrInSwitch: ['0f', '10', '11', '12', '13', '14'],
      currentAcIndex: 0, // 交流当前下标
      currentDcIndex: '', // 直流当前下标
      currentIndex: 0, // 当前选择的坐标
      type: 'Ac', // 判断下边的类型
      disableFlag1: true,
      disableFlag2: true,
      disableFlag3: false,
      btnD1: false,
      btnD2: false,
      btnD3: false,
      timeHandle: '',
      AcIcon: [
        {
          icon0: '',
          icon1: '',
          icon2: '',
          icon3: '',
        },
        {
          icon0: '',
          icon1: '',
          icon2: '',
          icon3: '',
        },
        {
          icon0: '',
          icon1: '',
          icon2: '',
          icon3: '',
        },
      ],
      DcIcon: [
        {
          icon0: '',
          icon1: '',
          icon2: '',
          icon3: '',
          icon4: '',
          icon5: '',
        },
        {
          icon0: '',
          icon1: '',
          icon2: '',
          icon3: '',
          icon4: '',
          icon5: '',
        },
        {
          icon0: '',
          icon1: '',
          icon2: '',
          icon3: '',
          icon4: '',
          icon5: '',
        },
        {
          icon0: '',
          icon1: '',
          icon2: '',
          icon3: '',
          icon4: '',
          icon5: '',
        },
      ],
      AcDisable: [
        {
          d0: false,
          d1: false,
          d2: false,
          d3: false,
        },
        {
          d0: false,
          d1: false,
          d2: false,
          d3: false,
        },
        {
          d0: false,
          d1: false,
          d2: false,
          d3: false,
        },
      ],
      DcDisable: [
        {
          d0: false,
          d1: false,
          d2: false,
          d3: false,
          d4: false,
          d5: false,
        },
        {
          d0: false,
          d1: false,
          d2: false,
          d3: false,
          d4: false,
          d5: false,
        },
        {
          d0: false,
          d1: false,
          d2: false,
          d3: false,
          d4: false,
          d5: false,
        },
        {
          d0: false,
          d1: false,
          d2: false,
          d3: false,
          d4: false,
          d5: false,
        },
      ],
      username: '',
      selected1: [],
      selected2: [],
      selected3: [],
      timerNum: 0,
      cuttNum: 20,
      listIndex: -1,
      list1F: '',
      list2F: '',
      timer: null,
      till_ac: false,
      till_dc: false,
      till_1: false,
      till_2: false,
      till_parent: true, // true执行获取全部
      acContentLoad: false, // 交流信息面板控制加载样式
      dcContentLoad: false, // 直流信息面板控制加载样式
      itemTimer: null, // 控制面板切换定时器
      messagesTips: '正在加载信息面板数据,请稍等!',
      isbutton: false,
      parentEventTimer: null,
      isAcInfor: false,
      isDcInfor: false,
      clickType: '',
      count: '',
      dialogFormVisible: false,
      bindDeviceSearch: {
        deviceIp: '',
      },
      AddtableData: [],
      addLoading: false,
      addCurrentPage: 1, // 当前页数
      addPageSize: 10, // 每页显示行数
      addTotal: 0, // 总页数
      gzDiable: false,
      closeDisable: false,
      indexList: [],
      listArr: [],
      selectVal: '', // 绑定设备表格选择
      addSetTimer: null,
      row: {},
      unBindFlag: false,
      bindFlag: false,
      bindIndex: 0,
      unBindType: false,
      unBindIndex: 0,
      unBindTimer: null,
      secdFlag: false,
      tableMessage: '',
    }
  },
  components: { statusPage },
  watch: {
    // 只有改变currentAcIndex时候才有效果
    currentAcIndex: {
      immediate: true,
      handler: function (newVal, oldVal) {
        watchCurrentIndex(this, newVal, 'Ac', 'Dc')
        const index = newVal
        if (this.Ac.length < 1 || this.currentAcIndex === '') {
          return
        }
        // 初始开关disable状态
        initAcSwitch(this, index)
      },
    },
    // 只有改变currentAcIndex时候才有效果
    currentDcIndex: {
      immediate: true,
      handler: function (newVal, oldVal) {
        watchCurrentIndex(this, newVal, 'Dc', 'Ac')
        const index = newVal
        if (this.Dc.length < 1 || this.currentDcIndex === '') {
          return
        }
        // 初始开关disable状态
        initDcSwitch(this, index)
      },
    },
    // 检测交流信息面板提交数据是否有更改
    AcContent: {
      deep: true,
      handler: function (newVal, oldVal) {
        if (this.currentAcIndex === '') {
          return
        }
        for (let i = 0; i < newVal[this.currentAcIndex].length; i++) {
          for (const k in newVal[this.currentAcIndex][i]) {
            if (newVal[this.currentAcIndex][i][k] !== this.AcContentClone[this.currentAcIndex][i][k]) {
              for (const m in this.AcContent[this.currentAcIndex][0]) {
                if (k === m) {
                  this.selected1.push(k)
                }
              }
              for (const m in this.AcContent[this.currentAcIndex][1]) {
                if (k === m) {
                  this.selected2.push(k)
                }
              }
            }
          }
        }
      },
    },
    // 检测直流流信息面板提交数据是否有更改
    DcContent: {
      deep: true,
      handler: function (newVal, oldVal) {
        // console.log(newVal, oldVal)
        if (this.currentDcIndex === '') {
          return
        }
        for (let i = 0; i < newVal[this.currentDcIndex].length; i++) {
          for (const k in newVal[this.currentDcIndex][i]) {
            if (newVal[this.currentDcIndex][i][k] !== this.DcContentClone[this.currentDcIndex][i][k]) {
              for (const m in this.DcContent[this.currentDcIndex][0]) {
                if (k === m) {
                  this.selected1.push(k)
                }
              }
              for (const m in this.DcContent[this.currentDcIndex][1]) {
                if (k === m) {
                  this.selected2.push(k)
                }
              }
              for (const m in this.DcContent[this.currentDcIndex][2]) {
                if (k === m) {
                  this.selected3.push(k)
                }
              }
            }
          }
        }
      },
    },
  },
  created: function () {
    this.UUID = getUUID(32, 16)
    this.username = localStorage.getItem('userName') // 用户登录名
    this.createSocket() // websocket
    if (this.loading) {
      this.timer = setTimeout(() => {
        this.$message.error(overTimeTips)
        this.loading = false
      }, intervalTime)
    } else {
      clearTimeout(this.timer)
    }
  },
  methods: {
    // 建立websocket连接
    createSocket() {
      // // 在main.js或需要使用的地方引入并建立连接
      this.socket && this.socket.close()
      if (!this.socket) {
        console.log('建立websocket连接')
        this.socket = new WebSocket(newSocket(this.username, this.UUID))
        this.socket.onopen = this.open
        this.socket.onmessage = this.getMessage
        this.socket.onerror = this.onerror
        this.socket.onclose = this.onclose
      } else {
        console.log('websocket已连接')
      }
    },
    open() {
      this.getFirstId() // 第一包数据
      sendPing(this) // 发送心跳
    },
    // send第一次数据
    getFirstId() {
      // 0003000d 交流数量    0003000c 直流数量
      const list = [
        { command_id: '0003000c', value: '' },
        { command_id: '0003000d', value: '' },
      ]
      send(this, '01', list)
    },
    getMessage: function (msg) {
      // 接收到消息回复ok
      switch (isJSON(msg.data)) {
        case false: // 主板实时数据
          break
        case true:
          var SN = localStorage.getItem('SN')
          this.socket.send(`TILL${SN}OK`)
          if (isJSON(msg.data) && typeof JSON.parse(msg.data) === 'object' && 'obj') {
            // json字符串
            const res = JSON.parse(msg.data)
            // 状态码错误提示
            if (res.host_status !== '0000') {
              // errorTips(res.host_status)
              errorTips(res.host_status, res.tips)
              // 清除加载中样式
              reset(this, this.type)
              // 重置选中控制面板的样式
              initSwitch(this)
              this.loading = false
              this.acContentLoad = false
              this.dcContentLoad = false
              clearTimeout(this.timer)
              this.unBindFlag = false
              this.bindFlag = false
              this.closeDisable = false
              this.submitBtn = true
              // 清除按钮加载状态 - 要加
              return
            }
            switch (Number(res.doing)) {
              case 1: // 读取数据
                console.log('通道信息配置-01:' + new Date(), res)
                if (res.list.length > 0) {
                  for (let i = 0; i < res.list.length; i++) {
                    const id = res.list[i].command_id.toLowerCase()
                    const content = res.list[i].value
                    // 得到通道数 以及发送请求 start
                    switch (id) {
                      case '0003000c':
                        // 获取直流数量
                        if (Number(content)) {
                          this[`R_${id}`] = Number(content)
                          this.list1F = Number(content)
                        }
                        break
                      case '0003000d':
                        // 获取交流数量
                        if (Number(content)) {
                          // 判断是否是数字
                          this[`R_${id}`] = Number(content)
                          this.list2F = Number(content)
                          this.till_ac = true
                        }
                        break
                      default:
                    }
                    // 得到通道数 以及发送请求 end
                    // 交流 控制面板数据
                    if (this.R_0003000d > 0 && this.till_2) {
                      getKZMB(this, res.list, 'Ac')
                      if (this.till_parent) {
                        this.till_ac = false
                        this.till_dc = true
                      }
                    }
                    // 直流控制面板数据
                    if (this.R_0003000c > 0 && this.till_1) {
                      getKZMB(this, res.list, 'Dc')
                      if (this.till_parent) {
                        this.till_dc = false
                      }
                    }
                    // 交流信息面板1
                    if (this.currentAcIndex !== '') {
                      getXXMB(this, id, content, 'Ac')
                    }
                    // 直流信息面板
                    if (this.currentDcIndex !== '') {
                      getXXMB(this, id, content, 'Dc')
                    }
                    // clone 通道信息面板数据-用于检测提交是否有更改
                    this.AcContentClone = JSON.parse(JSON.stringify(this.AcContent))
                    this.DcContentClone = JSON.parse(JSON.stringify(this.DcContent))
                  }
                }
                if (this.list2F !== '' && this.till_ac) {
                  getlist2(this, this.list2F)
                  this.till_2 = true
                }
                if (this.list1F !== '' && this.till_dc) {
                  getlist1(this, this.list1F)
                  this.till_1 = true
                }
                // this.till_1, this.till_2为false 清除loading
                if (!this.till_1 && !this.till_2) {
                  // 获取控制面板数据第一次时候应该出现loading
                  this.loading = false
                }
                // console.log(this.type, this.currentAcIndex, this.currentDcIndex)
                break
              case 2:
                // 写入数据
                console.log('通道信息配置-02:' + new Date(), res)
                var listS = []
                var successList = []
                res.list.forEach((item, index) => {
                  const key = item.command_id.toLowerCase()
                  // const val = item.value
                  let val
                  if (item.status === '0001' || item.status === '2000') {
                    // 状态0001修改成功
                    // 通道控制面板-开关状态
                    switch (this.type) {
                      case 'Ac':
                        var acIndex = this.currentAcIndex
                        // key.charAt(key.length-1)
                        // str.indexOf("2") != -1
                        switch (key.indexOf('03000000') !== -1) {
                          case true: // 跳合闸
                            // 判断开关是否开启
                            // if (Number(this.Ac[acIndex][`R_010f000${acIndex + 5}`]) === 0) {
                            //   val = 1 // 开启
                            // } else {
                            //   val = 0 // 关闭
                            // }
                            // this.Ac[acIndex][`R_010f000${acIndex + 5}`] = val
                            // 更新于2021/04/26
                            console.log('修改跳合闸')
                            if (Number(this.Ac[acIndex][`R_0102001${acIndex + 5}`]) === 0) {
                              val = 1 // 开启
                            } else {
                              val = 0 // 关闭
                            }
                            this.Ac[acIndex][`R_0102001${acIndex + 5}`] = val
                            break
                          default:
                            if (key === `000${this.AcArr[acIndex]}0003`) {
                              // 通道设备名称
                              val = this.AcContent[acIndex][0][`R_${key}`]
                            } else {
                              if (Number(this.Ac[acIndex][`R_${key}`]) === 1) {
                                // 设置关闭的值
                                val = 0
                                if (key === `000${this.AcArr[acIndex]}0002`) {
                                  this.AcDisable[1][`d${acIndex}`] = true
                                  this.AcDisable[2][`d${acIndex}`] = true
                                  this.disableFlag1 = true
                                  this.disableFlag2 = true
                                }
                              } else {
                                // 设置开启的值
                                val = 1
                              }
                            }
                            this.Ac[this.currentAcIndex][`R_${key}`] = val
                            break
                        }
                        // var acIndex = this.currentAcIndex
                        this.AcDisable[0][`d${acIndex}`] = false
                        // 初始开关disable状态
                        if (acIndex !== '') {
                          initAcSwitch(this, acIndex)
                        }
                        break
                      case 'Dc':
                        var dcIndex = this.currentDcIndex
                        // 判断返回id是否包含03000000  true跳合闸开关
                        switch (key.indexOf('03000000') !== -1) {
                          case true:
                            // 判断开关状态
                            if (Number(this.Dc[this.currentDcIndex][`R_010200${this.OnOrInSwitch[this.currentDcIndex]}`]) === 0) {
                              val = 1
                            } else {
                              val = 0
                            }
                            this.Dc[this.currentDcIndex][`R_010200${this.OnOrInSwitch[this.currentDcIndex]}`] = val
                            break
                          default:
                            if (key === `000${this.DcArr[this.currentDcIndex]}0005`) {
                              val = this.DcContent[this.currentDcIndex][0][`R_${key}`]
                            } else {
                              // if (Number(this.Dc[this.currentDcIndex][`R_${key}`]) === 1) {
                              //   val = 0
                              //   if (key === `000${this.DcArr[this.currentDcIndex]}0009`) {
                              //     val = 2
                              //   }
                              // } else {
                              //   val = 1
                              // }
                              if (Number(this.Dc[this.currentDcIndex][`R_${key}`]) === 0) {
                                val = 1
                                if (key === `000${this.DcArr[this.currentDcIndex]}0009`) {
                                  val = 2
                                }
                              } else {
                                val = 0
                              }
                            }
                            this.Dc[this.currentDcIndex][`R_${key}`] = val
                        }
                        this.DcDisable[0][`d${dcIndex}`] = false
                        // 初始开关disable状态
                        if (dcIndex !== '') {
                          initDcSwitch(this, dcIndex)
                          // console.log('dcIndex:', dcIndex)
                          // console.log(this.DcDisable[1].d0, this.DcDisable[2].d0, this.DcDisable[3].d0)
                        }
                        break
                      default:
                    }
                    // 修改成功提示push到list
                    listS.push({
                      name: enumData[`R_${item.command_id}`],
                      result: '修改成功',
                      status: 0,
                      id: item.command_id,
                    })
                    this.unBindIndex++
                    this.bindIndex++
                    // 保存修改成功的端口和目的IP
                    successList.push(getSuccess(this, item.command_id))
                    // 修改成功 清空缓存
                    this.selected1 = []
                    this.selected2 = []
                    this.selected3 = []
                  } else {
                    // 修改失败
                    listS.push({
                      name: enumData[`R_${item.command_id}`],
                      // result: listTips(item.status),
                      result: listTips(item.remarks),
                      status: 1,
                      id: item.command_id,
                    })
                  }
                })
                // 绑定设备 100%成功 请求接口同步到资产
                if (this.closeDisable && listS.length === this.bindIndex) {
                  this.bindZiChan(listS)
                } else if (this.unBindFlag && this.unBindIndex >= listS.length) {
                  this.unBindZiChan(listS)
                } else if (successList.length > 0 && this.secdFlag) {
                  // 主机修改端口成功同步修改资产
                  this.changeZiChan(successList, listS)
                } else {
                  // 修改数据提示
                  if (listS.length > 0) {
                    listStatusTips(this, { list: listS, code: '' })
                  }
                }
                this.bindFlag = false
                reset(this, this.type) // 只要进入2 不管成功还是失败都要清除样式
                this.selectVal = ''
                this.closeDisable = false
                break
              default:
            }
            // 重置选中控制面板的样式
            initSwitch(this)
            // 返回json 进入getMessage 清除timer
            clearTimeout(this.timer)
          }
          break
      }
    },
    // 通道控制面板切换事件
    goItem(index, item, type) {
      // 不满足条件return
      if (isRequire(this)) {
        return
      }
      // 解绑设备时不允许操作
      if (this.unBindFlag) {
        return
      }
      // if(this[`is${type}Infor`]){

      // }
      console.log(index)
      this[`is${type}Infor`] = false // 切换控制面板，重置信息面板
      // 判断点击的是不是按钮
      this.isbutton = false
      this.selected1 = []
      this.selected2 = []
      if (type === 'Dc') {
        this.selected3 = []
      }
      // 改变指向
      this.type = type
      // 更改选中项
      if (type === 'Dc') {
        this.currentDcIndex = index
        this.currentAcIndex = ''
        this.till_1 = false
      } else {
        this.currentDcIndex = ''
        this.currentAcIndex = index
        this.till_2 = false
      }
    },
    // 通道面板开关事件
    btnMessage(item, index, currentIndex, disable, Icon, key, number, type) {
      const typeCase = type.toLowerCase()
      // 先清除上一次定时器
      if (this.timeHandle) {
        clearTimeout(this.timeHandle) // 清除定时器
        this.timeHandle = null
      }
      // 开关事件
      if (this[currentIndex] !== index) {
        return
      }
      if (disable[`d${index}`]) {
        return
      }
      // 判断按钮 icon
      for (let i = 0; i < this[`${this.type}Icon`].length; i++) {
        if (this[`${this.type}Icon`][i][`icon${index}`] !== '') {
          return
        }
      }
      // 判断信息面板是否有加载中样式
      if (this[`${typeCase}ContentLoad`]) {
        this.$message.warning(this.messagesTips)
        return
      }
      this.bindFlag = true
      this.clickType = 0 // 设置为开关
      // 判断点击的是不是按钮
      this.isbutton = true
      // 设置点击项的开关icon
      Icon[`icon${index}`] = 'el-icon-loading'
      // 信息控制面板 - disable
      this.disableFlag1 = true
      this.disableFlag2 = true
      var val
      if (type === 'Dc') {
        this.disableFlag3 = true
      }
      for (let i = 0; i < this[`${type}Disable`].length; i++) {
        // 设置所有的不能点击
        this[`${type}Disable`][i][`d${index}`] = true
      }
      var list = []
      let listItem = []
      // 开关发送
      for (const k in item) {
        if (k === `R_${key}`) {
          switch (key) {
            // case `010f000${index + 5}`: // 交流通道跳合闸
            //   var acChannelNum = index + 7
            //   if (Number(item[k]) === 0 && item[k] !== '') {
            //     val = `${acChannelNum.toString(16)}1` // 发送开启指令
            //   } else {
            //     val = `${acChannelNum.toString(16)}0` // 发送关闭指令
            //   }
            //   key = '03000000'
            //   break
            // 更新于2021/04/26
            case `0102001${index + 5}`: // 交流通道跳合闸
              // console.log('进来了')
              var acChannelNum = index + 7
              // if (Number(item[k]) === 0 && item[k] !== '') {
              //   val = `${acChannelNum.toString(16)}1` // 发送开启指令
              // } else {
              //   val = `${acChannelNum.toString(16)}0` // 发送关闭指令
              // }
              // 更新于2021/04/26 0代表开启 其他都是关闭
              if (Number(item[k]) === 0) {
                val = `${acChannelNum.toString(16)}0` // 发送关闭指令
              } else {
                val = `${acChannelNum.toString(16)}1` // 发送开启指令
              }
              key = '03000000'
              break
            case `010200${this.OnOrInSwitch[index]}`: // 直流通道跳合闸
              var dcChannelNum = index + 1
              if (Number(item[k]) === 0 && item[k] !== '') {
                val = `${dcChannelNum.toString(16)}1` // 发送开启指令
              } else {
                val = `${dcChannelNum.toString(16)}0` // 发送关闭指令
              }
              key = '03000000'
              break
            case `000${this.DcArr[index]}0009`: // 直流通道通道保护使能
              if (Number(item[k]) === 0) {
                val = '2'
              } else {
                val = '0'
              }
              break
            case `000${this.AcArr[index]}0002`: // 交流通道使能关闭 发送IP使能关闭指令
              if (Number(item[k]) === 0) {
                val = '1'
                listItem = [{ command_id: key, value: val }]
              } else {
                val = '0'
                listItem = [{ command_id: key, value: val }]
                if (this.Ac[index][`R_000${this.AcArr[index]}0001`] !== 0) {
                  listItem.push({ command_id: `000${this.AcArr[index]}0001`, value: '0' })
                }
              }
              break
            case `000${this.DcArr[index]}000a`: // 直流通道使能关闭 发送IP使能和通道保护使能关闭指令
              if (Number(item[k]) === 0) {
                val = '1'
                listItem = [{ command_id: key, value: val }]
              } else {
                val = '0'
                console.log('通道保护使能', `000${this.DcArr[index]}0009`)
                console.log('IP使能', `000${this.DcArr[index]}0008`)
                listItem = [{ command_id: key, value: val }]
                console.log('通道保护使能', this.Dc[index][`R_000${this.DcArr[index]}0009`])
                console.log('IP使能', this.Dc[index][`R_000${this.DcArr[index]}0008`])
                if (this.Dc[index][`R_000${this.DcArr[index]}0009`] !== 0) {
                  listItem.push({ command_id: `000${this.DcArr[index]}0009`, value: '0' })
                }
                if (this.Dc[index][`R_000${this.DcArr[index]}0008`] !== 0) {
                  listItem.push({ command_id: `000${this.DcArr[index]}0008`, value: '0' })
                }
                // listItem = [
                //   { command_id: key, value: val },
                //   { command_id: `000${this.DcArr[index]}0009`, value: '0' },
                //   { command_id: `000${this.DcArr[index]}0008`, value: '0' },
                // ]
              }
              break
            default:
              if (Number(item[k]) === 0) {
                val = '1'
              } else {
                val = '0'
              }
          }
        }
      }
      if (key === `000${this.AcArr[index]}0002` || key === `000${this.DcArr[index]}000a`) {
        list = listItem
      } else {
        list.push({
          command_id: key,
          value: val,
        })
      }
      // 发送数据
      send(this, '02', list)
      this.timeHandle = setTimeout(() => {
        if (Icon[`icon${index}`] !== '' || disable[`d${index}`]) {
          console.log(Icon[`icon${index}`], disable[`d${index}`], index)
          Icon[`icon${index}`] = ''
          this.bindFlag = false
          reset(this, type)
          // 重置选中控制面板的样式
          initSwitch(this)
          this.$message.error('修改失败 稍后重试')
        }
      }, intervalTime)
    },
    // 交流通道提交按钮 - 1
    AcFisrtSubmit(index) {
      if (this.AcContent[this.currentAcIndex][0][`R_000${this.AcArr[this.currentAcIndex]}0007`].length !== 20) {
        this.$message.error('国标编码为20位')
        return
      }
      if (this.AcContent[this.currentAcIndex][0][`R_000${this.AcArr[this.currentAcIndex]}0008`].length !== 12) {
        this.$message.error('第三方关联编码为12位')
        return
      }
      submitBtn(this, index, 0, 'Ac')
    },
    // 交流通道提交按钮 - 2
    AcSecondSubmit(index) {
      // 提交IP/子网掩码/端口
      const ref = this.$refs.refAc
      ref.validate(async (valid) => {
        // console.log(valid)
        if (!valid) {
          return
        }
        // console.log('提交了')
        submitBtn(this, index, 1, 'Ac')
      })
    },
    // 直流通道提交按钮 - 1
    DcFisrtSubmit(index) {
      if (this.DcContent[this.currentDcIndex][0][`R_000${this.DcArr[this.currentDcIndex]}000d`].length !== 20) {
        this.$message.error('国标编码为20位')
        return
      }
      if (this.DcContent[this.currentDcIndex][0][`R_000${this.DcArr[this.currentDcIndex]}000e`].length !== 12) {
        this.$message.error('第三方关联编码为12位')
        return
      }
      submitBtn(this, index, 0, 'Dc')
    },
    // 直流通道提交按钮 - 2
    secondSubmit(index) {
      // 提交IP/子网掩码/端口
      const ref = this.$refs.refDc
      ref.validate(async (valid) => {
        if (!valid) {
          return
        }
        submitBtn(this, index, 1, 'Dc')
      })
    },
    // 直流通道提交按钮 - 3
    DcLastSubmit(index) {
      submitBtn(this, index, 2, 'Dc')
    },
    // 获取图片地址
    getImgUrl(icon) {
      return require('@/assets/images/' + icon + '.png')
    },
    // 修改提示框
    closeDialog(data) {
      this.dialogStstusVisible = data
    },
    // 提交和开关按钮提示框确定事件
    parentEvent(data) {
      // clickType   0按钮 1提交按钮
      clearTimeout(this.parentEventTimer)
      let currentIndex = null
      let type = ''
      // if (!this.isbutton) {
      //   // 信息面板提交只改变状态
      //   this.dialogStstusVisible = data
      //   return
      // }
      if (this.currentAcIndex !== '') {
        currentIndex = this.currentAcIndex
        type = 'Ac'
      } else {
        currentIndex = this.currentDcIndex
        type = 'Dc'
      }
      var list = []
      // 0开关   1提交  2解绑  3绑定设备
      switch (this.clickType) {
        case 0:
          againData(this, this[`${type}`][currentIndex], currentIndex)
          break
        case 1:
          againData(this, this[`${type}Content`][currentIndex][this.count], currentIndex)
          break
        case 2: // 解绑设备
          list = []
          this[`${type}Content`][currentIndex].forEach((item) => {
            for (const k in item) {
              // console.log(k, '-----', k.replace('R_'))
              list.push({ command_id: k.replace('R_', ''), value: '' })
            }
          })
          // 发送数据
          send(this, '01', list)
          break
        case 3: // 绑定设备
          list = []
          if (type === 'Ac') {
            list = [
              { command_id: `000${this.AcArr[this.currentAcIndex]}0003`, value: '' },
              { command_id: `000${this.AcArr[this.currentAcIndex]}0004`, value: '' },
              { command_id: `000${this.AcArr[this.currentAcIndex]}0006`, value: '' },
            ]
          } else {
            list = [
              { command_id: `000${this.DcArr[this.currentDcIndex]}0005`, value: '' },
              { command_id: `000${this.DcArr[this.currentDcIndex]}0006`, value: '' },
              { command_id: `000${this.DcArr[this.currentDcIndex]}000c`, value: '' },
            ]
          }
          // 发送数据
          send(this, '01', list)
          break
        default:
      }
      // if (this.clickType === 0) {
      //   againData(this, this[`${type}`][currentIndex], currentIndex)
      // } else {
      //   againData(this, this[`${type}Content`][currentIndex][this.count], currentIndex)
      // }
      this.dialogStstusVisible = data
      if (type === 'Ac') {
        this.till_2 = true
      } else {
        this.till_1 = true
      }
      this.till_parent = false // 如果为false不在获取全部的控制面板
      this.loading = true
      this.parentEventTimer = setTimeout(() => {
        this.loading = false
      }, intervalTime)
    },
    // 展示信息面板
    displayInfor(type, i) {
      // 解绑设备时不允许操作
      if (this.unBindFlag) {
        return
      }
      const typeCase = type.toLowerCase()
      this.type = type
      // 如果在加载中需要等待加载完成
      if (this[`${typeCase}ContentLoad`]) {
        return
      }
      // 不满足条件return
      if (isRequire(this)) {
        return
      }
      // 点击不是选择当前控制面板的显示隐藏 return
      const index = this[`current${type}Index`]
      if (index !== i) {
        return
      }
      // 判断定时器 有就清除
      if (this.itemTimer) {
        clearTimeout(this.itemTimer)
      }
      // 判断信息面板显示隐藏按钮的状态
      switch (this[`is${type}Infor`]) {
        case true:
          this[`is${type}Infor`] = false
          break
        default:
          this[`is${type}Infor`] = true
          // 清除上一次的表单验证
          this.$nextTick(() => {
            const ref = this.$refs[`ref${type}`]
            ref.resetFields()
          })
          break
      }
      // 显示时获取信息面板信息
      if (this[`is${type}Infor`]) {
        // 信息面板加载中样式
        this[`${typeCase}ContentLoad`] = true
        // 设置控制面板选中项 按钮disable 为 true
        this[`${type}Disable`].forEach((item) => {
          item[`d${index}`] = true
        })
        // 发送数据
        send(this, '01', sendContent(this, type, index))
      }
      // 设置定时器
      this.itemTimer = setTimeout(() => {
        if (this[`${typeCase}ContentLoad`]) {
          this[`${typeCase}ContentLoad`] = false
          // 清除控制面板选中项 按钮disable 为 false
          this[`${type}Disable`].forEach((item) => {
            item[`d${index}`] = false
          })
          this.$message.error(overTimeTips)
        }
      }, intervalTime)
    },
    // 添加设备页面-设备列表
    async initAddItem() {
      this.addLoading = true
      // const addItemObj = JSON.parse(localStorage.getItem('addItemObj'))
      const XQBM = localStorage.getItem('XQBM')
      // XQBM
      const params = new URLSearchParams()
      params.append('userId', JSON.parse(getUrl('userconter')).id)
      params.append('QCZCLX', 53) // 不返回主机
      params.append('ZCMC_IP_XH', this.bindDeviceSearch.deviceIp)
      params.append('M_', this.addCurrentPage) // 当前页
      params.append('N_', this.addPageSize) // 每页显示行数
      params.append('BDZT', 0) // 绑定状态  0 未绑定
      // params.append('SF', addItemObj.sf) // 省份
      // params.append('CS', addItemObj.cs) // 城市
      // params.append('QX', addItemObj.qx) // 区县
      params.append('XZJD', XQBM) // 乡镇街道
      // console.log(params)
      const { data: res } = await this.$http.post(ziC + 'zcgl/selectZiChan', params)
      switch (res.code) {
        case '0000':
          for (let i = 0; i < res.data.list.length; i++) {
            res.data.list[i].icon = 0 // 图标样式
          }
          this.AddtableData = res.data.list
          this.addTotal = res.data.countList
          break
        default:
          this.AddtableData = []
          this.addTotal = 0
          this.tableMessage = res.message
          break
      }
      this.addLoading = false
      this.dialogFormVisible = true
    },
    // 绑定资产到数据库
    async bindZiChan(listS) {
      let bindCode = ''
      let tips = ''
      let tdbh = ''
      let tdmc = ''
      if (this.currentAcIndex !== '') {
        tdbh = this.currentAcIndex + 7
        tdmc = `交流通道${this.currentAcIndex + 1}`
      } else {
        tdbh = this.currentDcIndex + 1
        tdmc = `直流通道${tdbh}`
      }
      const list = [{ ZCID: this.row.id, TDBH: tdbh, TDMC: tdmc }]
      const params = new URLSearchParams()
      params.append('SN', localStorage.getItem('SN'))
      params.append('dbJson', JSON.stringify(list))
      const { data: res } = await this.$http.post(`${ziC}zcgl/updateBdZiChan`, params)
      if (res.code !== '0000') {
        bindCode = 0
        tips = '绑定到资产列表失败,请前往资产列表点击“同步主机信息”按钮。'
      } else {
        bindCode = 1
        tips = '成功绑定到资产列表。'
      }
      listStatusTips(this, { list: listS, code: bindCode, tips: tips })
      this.dialogFormVisible = false // 关闭绑定资产界面s
    },
    async unBindZiChan(listS) {
      let bindCode = ''
      let tips = ''
      let tdbh = ''
      if (this.currentAcIndex !== '') {
        tdbh = this.currentAcIndex + 7
      } else {
        tdbh = this.currentDcIndex + 1
      }
      const params = new URLSearchParams()
      params.append('SN', localStorage.getItem('SN'))
      params.append('TDBH', tdbh)
      params.append('KQJY', 1)
      params.append('KQTBJY', 1)
      const { data: res } = await this.$http.post(`${ziC}zcgl/jcBdByYwzj`, params)
      console.log('---------------', res)
      if (res.code !== '0000') {
        bindCode = 0
        tips = '解绑失败,请前往资产列表点击“同步主机信息”按钮。'
      } else {
        bindCode = 1
        tips = '解绑成功。'
      }
      listStatusTips(this, { list: listS, code: bindCode, tips: tips })
      this.unBindFlag = false
      this.bindFlag = false
    },
    async changeZiChan(list, listS) {
      let code = ''
      var index = ''
      switch (this.type) {
        case 'Ac':
          index = this[`current${this.type}Index`] + 7
          break
        default:
          index = this[`current${this.type}Index`] + 1
          break
      }
      const params = new URLSearchParams()
      params.append('SBXLH', localStorage.getItem('SN'))
      params.append('TDBH', index)
      list.forEach((item) => {
        params.append(item.key, item.content)
      })
      const { data: res } = await this.$http.post(`${ziC}zcgl/updateZiChanBySbxlh`, params)
      if (res.code !== '0000') {
        code = 0
      } else {
        code = 1
      }
      listStatusTips(this, { list: listS, code: code })
    },
    // 绑定设备
    bindDevice() {
      this.bindIndex = 0
      this.clickType = 3
      this.selectVal = ''
      this.bindDeviceSearch.deviceIp = ''
      this.initAddItem()
    },
    // 点击每一行事件
    addRowClick(row, column, event) {
      // console.log('------', row)
      const index = row.index
      this.selectVal = index
      this.row = row
      // console.log(this.row)
    },
    // 解绑设备
    unBindDevice(index) {
      this.unBindIndex = 0
      this.clickType = 2
      clearTimeout(this.unBindTimer)
      this.unBindFlag = true
      this.bindFlag = true
      this.AcDisable.forEach((item) => {
        for (const k in item) {
          item[k] = true
        }
      })
      this.DcDisable.forEach((item) => {
        for (const k in item) {
          item[k] = true
        }
      })
      this.disableFlag1 = true
      this.disableFlag2 = true
      this.disableFlag3 = true
      // const IP = localStorage.getItem('IP')
      const SN = localStorage.getItem('SN')
      // const XQ = localStorage.getItem('XQBM')
      if (this.socket.readyState === 1) {
        // console.log(`MAKEAIR-${IP}-${SN}-${XQ}-${index}-${this.username}${this.UUID}`)
        this.socket.send(`MAKEAIR-${SN}-${index}-${this.username}`)
      } else {
      }
      this.unBindTimer = setTimeout(() => {
        // console.log('~~~unBindDevice~~~', overTimeTips)
        if (this.unBindFlag) {
          this.unBindFlag = false
          this.bindFlag = false
          // 恢复当前选中样式
          reset(this, this.type)
          this.$message.error(overTimeTips)
        }
      }, intervalTime)
    },
    // 绑定设备界面-查询事件
    addOnSubmit() {
      this.selectVal = ''
      this.addCurrentPage = 1
      this.listArr = []
      this.initAddItem()
    },
    tableRowClassName({ row, rowIndex }) {
      // 把每一行的索引放进row
      row.index = rowIndex
    },
    // 绑定设备弹窗-关闭事件
    dialogClose() {
      if (this.closeDisable) {
        this.dialogFormVisible = true
        return
      }
      this.dialogFormVisible = false
    },
    // 添加设备页面-table设置列样式
    selectClass({ row, column, rowIndex, columnIndex }) {
      for (let i = 0; i < this.indexList.length; i++) {
        if (this.indexList[i] === row.id && columnIndex === 1) {
          return 'fontColor'
        }
      }
    },
    // 添加设备页面-table当选择项发生变化时会触发该事件
    selectC(row) {
      this.indexList = []
      for (let i = 0; i < row.length; i++) {
        this.indexList.push(row[i].id)
      }
    },
    // 添加设备页面-当用户手动勾选全选/行 Checkbox 时触发的事件
    selectF(selection, row) {
      // console.log(selection, row)
      this.num = selection.length
      this.selectionArr = selection
    },
    // 添加设备页面-分页currentPage 改变时会触发
    addHandleCurrentChange(val) {
      this.selectVal = ''
      this.addCurrentPage = val
      this.addShebei = {
        sblx: '',
        ss: '',
      }
      this.listArr = []
      this.num = 0
      this.initAddItem()
      // this.reductionTable()
    },
    // 添加设备页面-取消按钮
    cancelBtn() {
      this.dialogFormVisible = false
    },
    // 添加设备页面-确定按钮
    addDevice() {
      clearTimeout(this.addSetTimer)
      if (this.selectVal === '') {
        return this.$message.error('请选择需要挂在的设备!')
      }
      var list = []
      const row = this.row
      this.closeDisable = true // disable状态
      // 交流
      if (this.currentAcIndex !== '') {
        const acIndex = this.currentAcIndex
        var listChild = [
          {
            command_id: `000${this.AcArr[acIndex]}0003`, // 设备名称
            value: row.zcmc === '' ? 'NULL' : row.zcmc,
          },
          {
            command_id: `000${this.AcArr[acIndex]}0004`, // 目的ip地址
            value: row.ip === '' ? '127.0.0.1' : row.ip,
          },
          {
            command_id: `000${this.AcArr[acIndex]}0006`, // 端口
            value: row.gldk === '' ? '8080' : row.gldk,
          },
        ]
        list.push({
          td: this.currentAcIndex + 7,
          id: row.id,
          child: listChild,
          // {
          //   command_id: `000${this.AcArr[acIndex]}0005`, // 子网掩码
          //   value: row.zcmc,
          // }
        })
      }
      // 直流
      if (this.currentDcIndex !== '') {
        const dcIndex = this.currentDcIndex
        var dcListChild = [
          {
            command_id: `000${this.DcArr[dcIndex]}0005`, // 设备名称1
            value: row.zcmc === '' ? 'null' : row.zcmc,
          },
          {
            command_id: `000${this.DcArr[dcIndex]}0006`, // 目的ip地址
            value: row.ip === '' ? 'null' : row.ip,
          },
          {
            command_id: `000${this.DcArr[dcIndex]}000c`, // 端口
            value: row.gldk === '' ? 'null' : row.gldk,
          },
        ]
        list.push({
          td: this.currentDcIndex + 1,
          id: row.id,
          child: dcListChild,
          // {
          //   command_id: `000${this.AcArr[dcIndex]}0007`, // 子网掩码
          //   value: row.,
          // },
        })
      }
      // 发送数据
      send(this, '02', list[0].child)
      this.addSetTimer = setTimeout(() => {
        if (this.closeDisable) {
          this.closeDisable = false
          this.$message.error(overTimeTips)
        }
      }, intervalTime)
    },
    // 限制直流通道最后一列只能输入数字
    handleInput(value, currentIndex, id) {
      value = value.replace(/[^0-9]/g, '') // 限制只输入数字
      this.DcContent[currentIndex][2][`${id}`] = value
    },
    radioChange(row) {
      this.row = row
    },
    // 初始发送控制面板按钮id 和 信息面板id 函数 end
    onerror(e) {
      this.socket.close()
      clearInterval(this.setIntervalWesocketPush)
      console.log('连接失败')
    },
    onclose(e) {
      clearInterval(this.setIntervalWesocketPush)
      console.log('websocket已断开')
      this.loading = false
      this.$message.error('websocket已断开')
    },
  },
  destroyed() {
    this.socket.send('CLOSE>-<' + this.username) // 关闭页面前发送
    // 销毁监听
    clearInterval(this.setIntervalWesocketPush)
    this.socket.onclose = this.socket.close()
    clearTimeout(this.timer)
  },
}
</script>

<style lang="scss" scoped>
@import '@/assets/scss/role.scss';
</style>
